<template>
  <div class="mobile clearfix">
    <MobileHeader />

    <div class="clear hei40"></div>
    <div class="content">
      <div class="public-title clearfix pos-rel" style="margin-bottom:10px">
        <h2 class="pos-rel course">{{ date1.channelNameEn }}</h2>
        <h1 class="pos-abs">{{ date1.channelName }}</h1>
        <!-- <h3 class="pos-abs">{{ date1.title }}</h3> -->
        <!-- <div class="catage clearfix pos-abs">
          您所在位置： ><label
            v-for="(list1, index) in date1.channelList"
            :key="index"
            >{{ list1.channelName }} >
          </label>
          列表
        </div> -->
      </div>
      <ul class="article-list rad5 clearfix" v-if="date1.displayForm == '1'">
        <li class="clearfix pos-rel" v-for="(item, index) in date1.ipage.records" :key="index" @click="jump(item)">
          <h1 class="text-wid">{{ index + 1 }}. {{ item.title }}</h1>
          <span class="intro">
            {{ item.description }}
          </span>
          <span class="data pos-abs">{{ item.releaseDate }}</span>
        </li>
      </ul>

      <Ul class="block-list clearfix" v-else-if="date1.displayForm == '2'">
        <li class="clarfix" v-for="(item, index) in date1.ipage.records" :key="index">
          <!--        <li class="clarfix" v-for="(item,index) in date1.ipage.records" :key="index" @click="jump(item.id)" >-->
          <div class="con pos-rel clearfix">
            <img class="img" :src="item.titleImg" />
            <div class="pos-abs text clearfix">
              <h1>{{ item.title }}</h1>
              <span class="desc">{{ item.description | ellipsis }}</span>
            </div>
          </div>
        </li>
      </Ul>

      <!-- <Ul class="block-list clearfix" v-else-if="date1.displayForm=='3'">
            <li class="clarfix" v-for="(item,index) in date1.ipage.records" :key="index"  >
                &lt;!&ndash;        <li class="clarfix" v-for="(item,index) in date1.ipage.records" :key="index" @click="jump(item.id)" >&ndash;&gt;
                <div class="con pos-rel clearfix">
                    <img class="img" :src=item.titleImg>
                    <div class="pos-abs text clearfix">
                        <h1>{{item.title}}</h1>
                        <span class="desc">{{item.description | ellipsis}}</span>
                    </div>
                </div>
            </li>
        </ul>-->

      <!-- <ul class="article-list rad5 clearfix" v-else>
        <li class="clarfix" v-for="(item,index) in imgList" :key="index">
          <div class="con pos-rel clearfix">
            <img class="img" :src=item.img>
            <div class="pos-abs text clearfix">
              <h1>{{item.name}}</h1>
              <span class="desc">{{item.desc}}</span>
            </div>
          </div>
        </li>
      </ul> -->
    </div>
    <div class="page-list clearfix">
      <!-- <template v-for="count in date1.ipage.pages">
        <a @click="pagination($event, count)" :class="count == date1.ipage.current ? 'focus' : ''" :key="count" >{{ count }}</a>
      </template>-->
      <a @click="pagination($event, 1)">首页</a>
      <template v-for="count in date1.ipage.pages">
        <a @click="pagination($event, count)" :class="count == date1.ipage.current ? 'focus' : ''" :key="count" v-if="
          count <= date1.ipage.current + 5 && count > date1.ipage.current - 5
        ">{{ count }}</a>
      </template>
      <a @click="pagination($event, date1.ipage.pages)">尾页</a>
      共{{ date1.ipage.pages }}页 跳转至<input style="width: 22px" v-model="pages" @keyup.enter="goPage()" />页<a
        @click="goPage()">go</a>
    </div>
    <div class="clear hei20"></div>
    <MobileFooter />
  </div>
</template>

<script>
import _http from "../httpService";
import MobileHeader from "./MobileHeader.vue";
import MobileFooter from "./MobileFooter.vue";

export default {
  name: "HospitalSummedup",
  props: {
    msg: String,
  },
  components: {
    MobileHeader,
    MobileFooter,
  },
  data() {
    return {
      pageNo: 1,
      pages: 1,
      pageSize: 10,
      date1: {
        ipage: {},
        channelName: "",
        channelNameEn: "",
        channelContent: "",
      },
      dataList: [],
      isDisable: false,
      name: "",
      mobile: "",
      content: "",
    };
  },
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 20) {
        return value.slice(0, 20) + "...";
      }
      return value;
    },
  },
  methods: {
    jump: function (item) {
      if (item.titleColor == "zhuanjiajieshao") {
        this.$router.push({ path: "/mobileZhuanjlb/" + item.id });
      } else {
        this.$router.push({ path: "/MobileArticle/" + item.id });
      }
    },

    pagination: function (e, pageNo) {
      // console.log("dddd" + e.target.$el.class)
      this.pageNo = pageNo;

      _http
        .get(
          "/content/jcContent/listArticle?channelCode=" +
          this.$route.query.channelCode +
          "&pageNo=" +
          pageNo +
          "&pageSize=" +
          this.pageSize
        )
        .then((resp) => {
          if (resp.data.success) {
            this.date1 = resp.data.result;
          }
        })
        .catch((error) => console.log(error))
        .finally(() => (this.loading = false));
    },
    goPage: function () {
      this.pageNo = this.pages;
      _http
        .get(
          "/content/jcContent/listArticle?channelCode=" +
          this.$route.query.channelCode +
          "&pageNo=" +
          this.pages +
          "&pageSize=" +
          this.pageSize
        )
        .then((resp) => {
          if (resp.data.success) {
            this.date1 = resp.data.result;
          }
        })
        .catch((error) => console.log(error))
        .finally(() => (this.loading = false));
    },
  },

  watch: {
    //监听相同路由下参数变化的时候，从而实现异步刷新

    $route() {
      _http
        .get(
          "/content/jcContent/listArticle?channelCode=" +
          this.$route.query.channelCode +
          "&pageNo=" +
          this.pageNo +
          "&pageSize=" +
          this.pageSize
        )
        .then((resp) => {
          if (resp.data.success) {
            this.date1 = resp.data.result;
          }
        })
        .catch((error) => console.log(error))
        .finally(() => (this.loading = false));
    },
    immediate: true,
  },

  created() {
    _http
      .get(
        "/content/jcContent/listArticle?channelCode=" +
        this.$route.query.channelCode +
        "&pageNo=" +
        this.pageNo +
        "&pageSize=" +
        this.pageSize
      )
      .then((resp) => {
        if (resp.data.success) {
          this.date1 = resp.data.result;
        }
      })
      .catch((error) => console.log(error))
      .finally(() => (this.loading = false));
  },
};
</script>

<style lang="scss" scoped>
@import "../assets/css/public.css";
@import "../assets/css/public.scss";

@import "../assets/css/mobile.css";

.mobile {
  .one-block {
    .list {
      padding: 0.2rem;

      ul {
        height: 100%;
        width: 100%;

        li {
          width: 50%;
          cursor: pointer;
          text-align: center;
          color: #797979;

          .con {
            margin: 0.2rem;
            padding: 0.4rem 0rem;
            box-shadow: 0px 0px 0.2rem rgba(0, 0, 0, 0.1);

            h2 {
              font-size: 0.3rem;
              height: 0.4rem;
              line-height: 0.4rem;
              padding: 0.2rem 0rem 0rem 0rem;
            }

            i {
              font-size: 0.9rem;
              color: #0eb4b6;
            }

            p {
              color: #a0a0a0;
              font-size: 0.25rem;
              line-height: 0.4rem;
              height: 0.4rem;
              font-weight: bold;
            }
          }
        }

        li:last-child {
          border: 0px;
        }

        li.focus {
          position: relative;
          border: 0px;
          color: #fff;

          i,
          p {
            color: #fff;
          }
        }

        li.focus {
          .con {
            background: -webkit-linear-gradient(90deg,
                #0fb4b6,
                #8ddadc);
            /* Safari 5.1 - 6.0 */
            background: -o-linear-gradient(90deg,
                #0fb4b6,
                #8ddadc);
            /* Opera 11.1 - 12.0 */
            background: -moz-linear-gradient(90deg,
                #0fb4b6,
                #8ddadc);
            /* Firefox 3.6 - 15 */
            background: linear-gradient(90deg,
                #0fb4b6,
                #8ddadc);
            /* 标准的语法（必须放在最后） */
          }
        }
      }
    }
  }

  .two-block {
    width: 100%;
    margin-bottom: 0.2rem;

    .tit {
      padding: 0.15rem 0rem;
      border-bottom: 1px solid #ddd;
      margin-bottom: 0.2rem;

      h1 {
        font-size: 0.3rem;
        color: #333333;
      }

      .more {
        font-size: 0.25rem;
        cursor: pointer;
        line-height: 0.4rem;
        color: #0eb4b6;
      }
    }

    .img {
      width: 100%;
      height: 200px;
    }

    .li-list {
      font-size: 14px;

      li {
        cursor: pointer;
        text-align: left;
        padding: 8px 50px 4px 0px;
        color: #333;

        span {
          right: 0px;
          color: #444;
        }
      }

      li:hover {
        color: #0eb4b6;
        text-decoration: underline;
      }
    }
  }

  .three-block {
    padding: 0rem 0.2rem;

    .tit-one {
      text-align: left;

      h1 {
        font-size: 18px;
        color: #343434;
      }

      h2 {
        color: #999;
        font-size: 14px;
      }
    }

    .img1 {
      margin: 0.2rem 0rem;
      width: 100%;
      height: 6rem;
      background: url("../assets/images/20200513110635616.jpg") no-repeat center center;
    }

    .font {
      left: 0px;
      bottom: 0px;
      right: 0px;
      padding: 10px 10px 20px 20px;
      background: rgba(0, 0, 0, 0.5);
      color: #fff;
      text-align: left;

      h1 {
        font-size: 20px;
        font-weight: normal;
        line-height: 40px;
      }

      h2 {
        font-size: 14px;
        font-weight: normal;
        line-height: 25px;
      }
    }

    .r-list {
      width: 100%;

      .tit {
        border-bottom: 1px solid #dee4ec;
        margin: 0.3rem 0px 0.2rem 0rem;

        h1 {
          font-size: 0.3rem;
          line-height: 0.5rem;
          height: 0.5rem;
          padding-bottom: 0.1rem;
          text-align: left;
          margin-right: 0.4rem;
          color: #7d8794;
        }

        h1.focus {
          color: #222;
        }

        h1.focus:before {
          background: #4cc6c8;
        }

        h1:before {
          content: "";
          position: absolute;
          left: 0px;
          right: 0px;
          bottom: 0px;
          border-radius: 5px 10px 0px 0px;
          height: 4px;
          width: 1.2rem;
          background: transparent;
        }
      }

      .li-block {
        li {
          cursor: pointer;
          float: left;
          width: 50%;
          margin: 0.15rem 0px 0px 0px;

          span {
            display: block;
            margin: 0rem 0.2rem;
            padding: 0.2rem 0rem;
            border: 1px solid #e9ebf0;
            font-size: 0.25rem;
            text-align: center;
            background: #fff;
          }
        }

        li:hover {
          span {
            background: #4fc9ca;
            color: #fff;
            border: 1px solid #4fc9ca;
          }
        }
      }
    }
  }

  .four-block {
    margin: 0.3rem 0rem 0rem 0rem;
    padding: 0.2rem;

    .tit {
      margin: 0rem 0.1rem;

      h1 {
        font-size: 0.3rem;
        line-height: 0.5rem;
        text-align: left;
      }

      h2 {
        font-size: 0.25rem;
        color: #999;
        text-align: left;
      }
    }

    .img-list {
      margin-top: 0.1rem;

      li {
        cursor: pointer;
        float: left;
        width: 50%;

        .con {
          margin: 0.1rem;

          .img {
            width: 100%;
            height: 2.6rem;
          }

          .title {
            display: none;
            left: 0px;
            right: 0px;
            bottom: 2px;
            background: rgba(0, 0, 0, 0.5);
            color: #fff;
            font-size: 14px;
            text-align: center;
            font-weight: bold;
            padding: 10px 0px;
          }
        }

        .con:hover {
          box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);

          .title {
            display: block;
          }
        }
      }
    }

    .img-address {
      img {
        width: 100%;
      }
    }
  }
}
</style>

